package com.yupi.yuaicodemother.service;

import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.service.IService;
import com.yupi.yuaicodemother.model.dto.UserQueryRequest;
import com.yupi.yuaicodemother.model.dto.entity.User;
import com.yupi.yuaicodemother.model.vo.LoginUserVo;
import com.yupi.yuaicodemother.model.vo.UserVo;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 用户 服务层。
 *
 * @author 跟练鱼皮项目
 * @since 1.0.0
 */
@Service
public interface UserService extends IService<User> {
    /**
     * 用户注册
     *
     * @param userAccount   用户账户
     * @param userPassword  用户密码
     * @param checkPassword 校验密码
     * @return 新用户 id
     */
    long userRegister(String userAccount, String userPassword, String checkPassword);



    // 密码加密
    String getEncryptPassword(String userPassword);

    /**
     * 获取脱敏的已登录用户信息
     *
     * @return
     */
    LoginUserVo getLoginUserVO(User user);


    /**
     * 用户登录
     *
     * @param userAccount  用户账户
     * @param userPassword 用户密码
     * @param request
     * @return 脱敏后的用户信息
     */
    LoginUserVo userLogin(String userAccount, String userPassword, HttpServletRequest request);



    /**
     * 获取当前登录用户
     *
     * @param request
     * @return
     */
    User getLoginUser(HttpServletRequest request);



    /**
     * 用户注销
     *
     * @param request
     * @return
     */
    boolean userLogout(HttpServletRequest request);


    /**
     * 获取用户脱敏信息
     */
    UserVo getUserVo(User user);

    /**
     * 把前端传来的用户信息封装成flex的查询条件
     * @param  userQueryRequest
     * @return
     */
    QueryWrapper  getQueryWrapper(UserQueryRequest userQueryRequest);



    List<UserVo> getUserVoList(List<User> user);

}
